<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\common\model;

/**
 * 模型
 */
class InterestAllocation extends ModelBase
{

    protected $insert = ['create_time'];




    /**
     * 时间自动完成
     */
    public function setCreateTimeAttr()
    {

        return TIME_NOW;
    }
    /**
     * 时间获取器
     */
    public function getCreateTimeAttr($value)
    {

        return date('Y-m-d H:i:s',$value);
    }


    /**
     * 时间获取器
     */
    public function getCollectionMoneyTotalAttr()
    {

        return InterestAllocation::where(['id'=>['lt',$this->id+1]])->sum('collection_money');
    }
    /**
     * 时间获取器
     */
    public function getSubstituteMoneyTotalAttr()
    {

        return InterestAllocation::where(['id'=>['lt',$this->id+1]])->sum('substitute_money');
    }

    /**
     * 时间获取器
     */
    public function getCollectionCountTotalAttr()
    {

        return InterestAllocation::where(['id'=>['lt',$this->id+1]])->sum('collection_count');
    }

    /**
     * 时间获取器
     */
    public function getSubstituteCountTotalAttr()
    {

        return InterestAllocation::where(['id'=>['lt',$this->id+1]])->sum('substitute_count');
    }


    /**
     * 时间获取器
     */
    public function getFeedCountTotalAttr()
    {

        return InterestAllocation::where(['id'=>['lt',$this->id+1]])->sum('feed_count');
    }

}
